package com.itheima.stock.controller;

import com.itheima.stock.pojo.dommain.InnerMarketDomain;
import com.itheima.stock.pojo.dommain.Stock4EvrDayDomain;
import com.itheima.stock.pojo.dommain.Stock4MinuteDomain;
import com.itheima.stock.pojo.dommain.StockUpdownDomain;
import com.itheima.stock.servier.StockService;
import com.itheima.stock.vo.resp.PageResult;
import com.itheima.stock.vo.resp.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 定义股票相关接口控制器
 */
@RestController
@RequestMapping("/api/quot")
@Api(tags = "定义股票相关接口")
public class StockController {

    @Autowired
    private StockService stockService;
    /**
     * 获取国内大盘数据
     * @return
     */
    @GetMapping("/index/all")
    @ApiOperation(value = "获取国内大盘数据",notes = "获取国内大盘数据",httpMethod = "GET")
    public R<List<InnerMarketDomain>> getInnerMarket(){

        return stockService.getInnerMarket();
    }

    /**
     * 分页查询最新的股票交易数据
     * @param page 当前页
     * @param pageSze 每页大小
     * @return
     * @RequestParam :url路径传参
     * required 是否必须传参
     * defaultValue默认值
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",dataType = "int",name = "page",value = "当前页"),
            @ApiImplicitParam(paramType = "query",dataType = "int",name = "pageSize",value = "每页大小")
    })
    @ApiOperation(value = "分页查询最新的股票交易数据",notes = "分页查询最新的股票交易数据",httpMethod = "GET")
    @GetMapping("/stock/all")
    public R<PageResult<StockUpdownDomain>> getStockInfoByPage(@RequestParam(value = "page",required = false,defaultValue = "1")Integer page,
                                                               @RequestParam(value = "pageSize",required = false,defaultValue = "20") Integer pageSze){


        return    stockService.getStockInfoByPage(page, pageSze);

    }


    /**
     * 最新的股票交易数据- 前四条
     */
    @ApiOperation("最新的股票交易数据- 前四条")
    @GetMapping("/stock/increase")
    public R<List<StockUpdownDomain>> getStockInfoHome(){
return stockService. getStockInfoHome();

    }


    /**
     * 统计每分钟的涨停跌停记录数
     * 统计最新股票交易日内每分钟的涨跌停的股票数量
     */

    @ApiOperation("统计每分钟的涨停跌停记录数"
            + "\n" + "统计最新股票交易日内每分钟的涨跌停的股票数量")
    @GetMapping("/stock/updown/count")
    public R<Map<String,List>> getStockUpDown(){

        return stockService.getStockUpDown();
    }



    /**
     * 导出指定页excel
     * @param page 当前页面
     * @param pageSze 每页大小
     * @param response 返回头信息
     */

    @ApiOperation("导出指定页excel")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",dataType = "int",name = "page",value = "当前页"),
            @ApiImplicitParam(paramType = "query",dataType = "int",name = "pageSize",value = "每页大小")
    })

    @GetMapping("/stock/export")
    public void exportStockUpDownInfo(@RequestParam(value = "page",required = false,defaultValue = "1")Integer page,
                                      @RequestParam(value = "pageSize",required = false,defaultValue = "20") Integer pageSze,
                                      HttpServletResponse response){
        stockService.exportStockUpDownInfo(page,pageSze,response);


    }


    /**
     * 统计国内A股大盘T日和T-1日成交量对比功能（成交量为沪市和深市成交量之和）
     */
    @ApiOperation(value = "统计国内A股大盘T日和T-1日成交量对比功能（成交量为沪市和深市成交量之和）",notes = "统计国内A股大盘T日和T-1日成交量" ,httpMethod = "GET")
    @GetMapping("/stock/tradeAmt")
    public R<Map<String,List>> getComparedSockTradeAmt(){
      return stockService.getComparedSockTradeAmt();
    }


    /**
     *统计最新交易时间点下股票在各个涨幅区间的数量
     */
    @ApiOperation(value = "统计最新交易时间点下股票在各个涨幅区间的数量",httpMethod = "GET")
    @GetMapping("/stock/updown")
    public R<Map> getIncreaseRangInfo(){
        return stockService.getIncreaseRangInfo();
    }

    /**
     *获取指定股票t日分时数据
     */

    @ApiOperation(value = "获取指定股票t日分时数据",notes = "获取指定股票t日分时数据",httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType ="query",dataType = "string",name = "stockCode",required = true)
    })
   // @GetMapping("/stock/screen/time-sharing")
    @GetMapping("/stock/screen/time-sharing")
    public R<List<Stock4MinuteDomain>> getStockScreenTimeSharing(@RequestParam(value = "stockCode" ,required = true) String stockCode){

        return stockService.getStockScreenTimeSharing(stockCode);
    }


    /**
     * 统计指定股票的日K线数据
     * @param stockCode 股票编码
     * @return
     */
    @ApiOperation("统计指定股票的日K线数据")
    @GetMapping("/stock/screen/dkline")
    public R<List<Stock4EvrDayDomain>> getStockScreenDkLine(@RequestParam(value = "stockCode" ,required = true) String stockCode){

        return stockService.getStockScreenDkLine(stockCode);
    }
}



















